﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace GA.Server.ApiInfo
{
    [Serializable]
    public class ApiMissionDetail
    {
        public DateTime EndTime { get; private set; }
        public int AgencyId { get; private set; }
        public string AgencyName { get; private set; }
        public int Assists { get; private set; }
        public double BuffPoints { get; private set; }
        public int CharacterId { get; private set; }
        public string Class { get; private set; }
        public double DamageBot { get; private set; }
        public double DamagePlayer { get; private set; }
        public double DamageTaken { get; private set; }
        public int Deaths { get; private set; }
        public double DefensePoints { get; private set; }
        public double Healing { get; private set; }
        public int Kills { get; private set; }
        public int BotKills { get; private set; }
        public int PlayerKills { get; private set; }
        public int Level { get; private set; }
        public string MapName { get; private set; }
        public string MapFriendlyName { get; private set; }
        public int MapInstanceId { get; private set; }
        public double ObjectivePoints { get; private set; }
        public int PlayerId { get; private set; }
        public string PlayerName { get; private set; }
        public int PlayerTaskForce { get; private set; }
        public double Score { get; private set; }
        public string Type { get; private set; }
        public string WinningTaskForce { get; private set; }
        public int WinStatus { get; private set; }
        public int XpValue { get; private set; }

        public ApiMissionDetail()
        {
        }

        public ApiMissionDetail(XmlReader reader)
        {
            while (!reader.EOF)
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.Element)
                {
                    string name = reader.Name;
                    string value = ApiXmlNode.GetValue(reader);
                    switch (reader.Name)
                    {
                        case "a:assists": Assists = value == null ? -1 : int.Parse(value); break;
                        case "a:character_id": CharacterId = value == null ? -1 : int.Parse(value); break;
                        case "a:damage_bot": DamageBot = value == null ? -1 : double.Parse(value); break;
                        case "a:damage_player": DamagePlayer = value == null ? -1 : double.Parse(value); break;
                        case "a:deaths": Deaths = value == null ? -1 : int.Parse(value); break;
                        case "a:defense_pts": DefensePoints = value == null ? -1 : double.Parse(value); break;
                        case "a:endeddatetimeest":
                        case "a:EndedDateTimeEST": EndTime = value == null ? DateTime.MinValue : DateTime.Parse(value); break;
                        case "a:healing": Healing = value == null ? -1 : double.Parse(value); break;
                        case "a:kills": Kills = value == null ? -1 : int.Parse(value); break;
                        case "a:mapName": MapName = value; break;
                        case "a:map_friendly_name": MapFriendlyName = value; break;
                        case "a:map_instance_id": MapInstanceId = value == null ? -1 : int.Parse(value); break;
                        case "a:objective_pts": ObjectivePoints = value == null ? -1 : double.Parse(value); break;
                        case "a:playertaskforce": PlayerTaskForce = value == null ? -1 : int.Parse(value); break;
                        case "a:agency_name": AgencyName = value; break;
                        case "a:score": Score = value == null ? -1 : double.Parse(value); break;
                        case "a:type": Type = value; break;
                        case "a:winstatus": WinStatus = value == null ? -1 : int.Parse(value); break;
                        case "a:xp_value": XpValue = value == null ? -1 : int.Parse(value); break;
                        case "a:agency_id": AgencyId = value == null ? -1 : int.Parse(value); break;
                        case "a:winning_taskforce": WinningTaskForce = value; break;
                        case "a:buff_pts": BuffPoints = value == null ? -1 : int.Parse(value); break;
                        case "a:class": Class = value; break;
                        case "a:damage_taken": DamageTaken = value == null ? -1 : int.Parse(value); break;
                        case "a:kills_bots": BotKills = value == null ? -1 : int.Parse(value); break;
                        case "a:kills_players": PlayerKills = value == null ? -1 : int.Parse(value); break;
                        case "a:level": Level = value == null ? -1 : int.Parse(value); break;
                        case "a:player_id": PlayerId = value == null ? -1 : int.Parse(value); break;
                        case "a:player_name": PlayerName = value; break;
                    }
                }
            }
        }
    }
}
